package com.leon.lifeenginespace.spring;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @description: 生命周期
 * @author: WT
 * @date: 2024/4/28 21:34
 * @Version 1.0
 **/
@Slf4j
@Component
public class LifeCycleBean {

    //实例化
    public LifeCycleBean() {
        log.info("LifeCycleBean init");
    }

    //组件装入
    @Autowired
    public void autowire(@Value("${JAVA_HOME}") String home) {
        log.info("LifeCycleBean autowire{}", home);

    }

    //初始化
    @PostConstruct
    public void init() {
        log.info("LifeCycleBean init 初始化");
    }

    //销毁
    @PreDestroy
    public void destroy() {
        log.info("LifeCycleBean destroy 销毁");
    }

}